package com.example.demo.listen;

import org.flowable.engine.delegate.DelegateExecution;
import org.springframework.stereotype.Component;

import java.io.Serializable;

/**
 * 多人会签案例
 */
@Component("mulitiInstanceCompleteTask")
public class MulitiInstanceCompleteTask implements Serializable {

    /**
     * 完成任务时触发的方法
     * @param execution
     * @return
     */
    public boolean completeTask(DelegateExecution execution) {
        System.out.println("总的会签任务数量：" + execution.getVariable("nrOfInstances")
                + " - 当前获取的会签任务数量：" + execution.getVariable("nrOfActiveInstances")
                + " - 已经完成的会签任务数量：" + execution.getVariable("nrOfCompletedInstances"));
        // 有一个人同意就通过会签审批
        boolean flag = (Boolean) execution.getVariable("flag");
        System.out.println("当前意见：" + flag);
        return flag;
    }
}
